import request from '@/config/axios'

// ERP销售管理-生产单 VO
export interface SaleProductOrderVO {
  id: string // ID
  internalOrderNo: string // 内部订单号
  customerId: string // 客户ID
  customerName: string // 客户名称
  orderDate: Date // 订单日期
  deliveryDate: Date // 交货日期
  quotationId: string // 报价单ID
  quotationNo: string // 报价单号
  customerOrderNo: string // 客户订单号
  remark: string // 备注
  status: string // 状态
  approver: string // 审核人
  approveTime: Date // 审核时间
}

// ERP销售管理-生产单 API
export const SaleProductOrderApi = {
  // 查询ERP销售管理-生产单分页
  getSaleProductOrderPage: async (params: any) => {
    return await request.get({ url: `/erp/sale-product-order/page`, params })
  },

  // 查询ERP销售管理-生产单详情
  getSaleProductOrder: async (id: number) => {
    return await request.get({ url: `/erp/sale-product-order/get?id=` + id })
  },

  // 新增ERP销售管理-生产单
  createSaleProductOrder: async (data: SaleProductOrderVO) => {
    return await request.post({ url: `/erp/sale-product-order/create`, data })
  },

  // 修改ERP销售管理-生产单
  updateSaleProductOrder: async (data: SaleProductOrderVO) => {
    return await request.put({ url: `/erp/sale-product-order/update`, data })
  },

  // 删除ERP销售管理-生产单
  deleteSaleProductOrder: async (id: number) => {
    return await request.delete({ url: `/erp/sale-product-order/delete?id=` + id })
  },

  // 导出ERP销售管理-生产单 Excel
  exportSaleProductOrder: async (params) => {
    return await request.download({ url: `/erp/sale-product-order/export-excel`, params })
  },

// ==================== 子表（ERP销售管理-生产单明细） ====================

  // 获得ERP销售管理-生产单明细分页
  getSaleProductOrderDetailPage: async (params) => {
    return await request.get({ url: `/erp/sale-product-order/sale-product-order-detail/page`, params })
  },
  // 新增ERP销售管理-生产单明细
  createSaleProductOrderDetail: async (data) => {
    return await request.post({ url: `/erp/sale-product-order/sale-product-order-detail/create`, data })
  },

  // 修改ERP销售管理-生产单明细
  updateSaleProductOrderDetail: async (data) => {
    return await request.put({ url: `/erp/sale-product-order/sale-product-order-detail/update`, data })
  },

  // 删除ERP销售管理-生产单明细
  deleteSaleProductOrderDetail: async (id: number) => {
    return await request.delete({ url: `/erp/sale-product-order/sale-product-order-detail/delete?id=` + id })
  },

  // 获得ERP销售管理-生产单明细
  getSaleProductOrderDetail: async (id: number) => {
    return await request.get({ url: `/erp/sale-product-order/sale-product-order-detail/get?id=` + id })
  },

// ==================== 子表（ERP销售管理-物料信息） ====================
  // 查询销售订单明细物料分页
  getSaleProductOrderDetailMaterialPage: async (params: any) => {
    return await request.get({ url: `/erp/sale-product-order-detail-material/page`, params })
  },

  // 查询销售订单明细物料详情
  getSaleProductOrderDetailMaterial: async (id: number) => {
    return await request.get({ url: `/erp/sale-product-order-detail-material/get?id=` + id })
  },

  // 新增销售订单明细物料
  createSaleProductOrderDetailMaterial: async (data: SaleProductOrderDetailMaterialVO) => {
    return await request.post({ url: `/erp/sale-product-order-detail-material/create`, data })
  },

  // 修改销售订单明细物料
  updateSaleProductOrderDetailMaterial: async (params) => {
    return await request.put({ url: `/erp/sale-product-order-detail-material/update`, params })
  },

  // 删除销售订单明细物料
  deleteSaleProductOrderDetailMaterial: async (id: number) => {
    return await request.delete({ url: `/erp/sale-product-order-detail-material/delete?id=` + id })
  },

  // 导出销售订单明细物料 Excel
  exportSaleProductOrderDetailMaterial: async (params) => {
    return await request.download({ url: `/erp/sale-product-order-detail-material/export-excel`, params })
  },
  
//  ***************************新请求******************************
  getSaleProductOrderDetailById: async (id: number) => {
    return await request.get({ url: ``, id })
  },

  getSaleProductOrderPageById: async (params: any) => {
    return await request.get({ url: ``, params })
  },

  getSaleProductMtlPageById: async (id: number) => {
    return await request.get({ url: ``, id })
  },






}
